package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.StockQuery;
import com.gec.zhs.entity.po.Stock;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.StockService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 出入库信息表 Controller
 */
@RestController("stockController")
@RequestMapping("/stock")
public class StockController extends ABaseController{

	@Resource
	private StockService stockService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(StockQuery query){
		return getSuccessResponseVO(stockService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Stock bean) {
		stockService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Stock> listBean) {
		stockService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Stock> listBean) {
		stockService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getStockById")
	public ResponseVO getStockById(String id) {
		return getSuccessResponseVO(stockService.getStockById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateStockById")
	public ResponseVO updateStockById(Stock bean,String id) {
		stockService.updateStockById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteStockById")
	public ResponseVO deleteStockById(String id) {
		stockService.deleteStockById(id);
		return getSuccessResponseVO(null);
	}
}